"@ List of global variables"

[score:=, task:=, par:=]

hit(pts_ := 0, dummy_, d_, k_, pt_, ttask_) := prog(                                        
       dummy_ := random(0),                        
       score := 0,
       "@ you can enter a number of points as parameter",
       "@ of hit() or accept the random number", 
       "@ eg. hit(12) gives 12 points, hit() gives a random number",                                
       if(pts_= 0,                                
          d_ := 7 + RANDOM(4),                     
          d_ := pts_),
       "@ par = maximum number of allowed attempts",                              
       par := FLOOR(d_/2 + 0.5),                   
       "@ First point of tasklist",               
       task := [[RANDOM(23) - 11, RANDOM(13) - 6]],
       k_ := 1,                                   
       Loop(                                       
            If(k_ = d_,exit),                          
            "@ New point is generated",               
            pt_ := [RANDOM(23) - 11, RANDOM(13) - 6], 
            "@ Test routine to avoid double points",                         
            ttask_ := SELECT(pt_ = l_, l_, task),     
            If(ttask_ = [],                           
               task := APPEND([pt_], task),           
               k_ := k_ - 1),                          
            k_ :+ 1
           ),                                  
    RETURN task
    )

"@ Grid 28 horizontal, 15 vertical"

plline(equ_,yes_,resplot_,plot1_):=PROG(
       score :+1,
       yes_:=SELECT(SUBST(equ_,[x, y],v_)=true,v_,task),
       task:=SELECT(SUBST(equ_,[x,y],v_)=false,v_,task),
       IF(par-score=0,
          resplot_:=[(X+11.5)^2+(y+6.5)^2=0.6^2]),
       IF(par-score<0,
          resplot_:=VECTOR(-12.8+i<=x<=-12.2+i and -6.8<=y<=-6.2,i,1,score-par)),
       IF(par-score>0,
          resplot_:=VECTOR((x+12.5-i)^2+(y+6.5)^2<=0.4^2,i,1,par - score)),
       plot1_:=APPEND([equ_],
       VECTOR((x-yes_ sub i sub 1)^2+(y-yes_ sub i sub2)^2<= 0.3^2,i,1,DIM(yes_))),
       IF(
          DIM(task) /= 0,
                     plot1_,
                     APPEND(plot1_,resplot_)
         )
       )
